//商品详情页
import 'package:flutter/material.dart';
import 'package:test_xzkdemo/utils/weights/BannerFor.dart';

class GoodsDetailPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _GoodsDetailPageSate();
}

class _GoodsDetailPageSate extends State<GoodsDetailPage> {
  List<BannerItem> bannerList;

  @override
  void initState() {
    super.initState();
    print("启动了初始化方法-->initState");
  }

  @override
  Widget build(BuildContext context) {
    print("启动了build方法-->build");
    if (bannerList == null) bannerList = BannerItem.buildDataList();
    print(bannerList);
    return new Scaffold(
      appBar: new AppBar(
        centerTitle: true,
        title: Text('商品详情'),
      ),
      body: Container(
        child: Column(
          children: <Widget>[
            new BannerWidget(
              300.0,
              bannerList,
              bannerPress: (pos, item) {
                print('第 $pos 点击了');
                setState(() {
                  select = !select;
                });
              },
            ),
            _buildTagsList(),
          ],
        ),
      ),
    );
  }

  bool select = false;

  //创建标签列表
  Widget _buildTagsList() {
    Color selColor = Colors.grey;
    Color tagColor = Colors.white;
    if (select) {
      tagColor = Colors.blue;
      selColor = Colors.white;
    }
    return ChipTheme(
      //统一设置Chip组件样式
      data: ChipThemeData(
        backgroundColor: tagColor,
        disabledColor: Colors.yellow,
        selectedColor: Colors.blue,
        secondarySelectedColor: Colors.white,
        labelPadding: EdgeInsets.fromLTRB(10, 0, 10, 0),
        padding: EdgeInsets.only(left: 10, right: 10),
        shape: new StadiumBorder(
            side: new BorderSide(
          style: BorderStyle.solid,
          color: Color(0xffFF7F24),
        )),
        labelStyle: TextStyle(color: Colors.white),
        secondaryLabelStyle: TextStyle(color: Colors.white),
        brightness: Brightness.dark,
        elevation: 5,
        shadowColor: Colors.lime,
      ),
      child: Wrap(
        spacing: 6.0,
        children: <Widget>[
          Chip(
              label: Text(
            'Text',
            style: TextStyle(color: selColor),
          )),
          Chip(
            label: Text('TextFieldqqw', style: TextStyle(color: selColor)),
          ),
          Chip(
            label: Text('Form', style: TextStyle(color: selColor)),
          ),
          Chip(
            label: Text('Image', style: TextStyle(color: selColor)),
          ),
        ],
      ),
    );
  }
}
